import pylab
import numpy , sys , os
import numpy

def x_y(k, L):
    y = k // L
    x = k - y * L
    return x, y

params = sys.argv
print "Plik wejsciowy:", str(sys.argv)
L = 0

filename = params[1]
data  = numpy.loadtxt(filename)

#filename = "avesiec.txt"
#data  = numpy.loadtxt(filename)


L = int(data[0])
S = data[1:L*L+1]
N = L*L

conf = [[0 for x in range(L)] for y in range(L)]
for k in range(N):
    x, y = x_y(k, L)
    conf[x][y] = S[k]


pylab.imshow(conf, extent = [0, L, 0, L], interpolation='nearest',vmin=-1.0,vmax=1.0)
pylab.set_cmap('hot')
pylab.colorbar()
pylab.title(filename)

pylab.savefig(filename + '.png')
#pylab.show()

